package atom.core0.util.tree;


import java.util.Map;

public class TreeHelper
{
	//如果有02.01 但没有02 会提示一个告警信息
	public static void buildTree(INode root, Map<String,INode> nodeMap) 
	{

		String parentNodeId="";
		INode node=null;
		INode parentNode=null;
		for(Map.Entry<String,INode> entry:nodeMap.entrySet())
		{
			//menuLevel = entry.getKey();
			node = (INode)entry.getValue();
			parentNodeId = node.getParent();
			
			if (parentNodeId.equals(""))
				root.addSon(node);
			else
			{
				parentNode = nodeMap.get(parentNodeId);
				if (parentNode==null)
				{
					System.out.println("没有找到父节点"+parentNodeId);
				}
				else
					parentNode.addSon(node);
			}
		}
	}
	public static MyNode buildTree(Map<String,INode> nodeMap) 
	{
		MyNode root = new MyNode();
		root.setId("");
		root.setName("root");
		
		buildTree(root,nodeMap);
		
		return root;
	}

}
